// NOTE:this is an file for build and watch project file.
const { task, src, dest, watch, parallel, series } = require("gulp");
const del = require("del");
const vinylPaths = require("vinyl-paths");
const ts = require("gulp-typescript");

var tsProject = ts.createProject("tsconfig.json");

function buildTS() {
  return tsProject.src().pipe(tsProject()).js.pipe(dest("dist"));
}

function copyJS() {
  return src("src/**/*.js").pipe(dest("dist"));
}

function clean() {
  return src("dist/*").pipe(vinylPaths(del));
}

task("ts", buildTS);
task("js", copyJS);
task("clean", clean)

task("watch", function () {
  watch(["src"], series(clean, parallel(buildTS, copyJS)));
});

task("build", parallel(buildTS, copyJS));
